
import os;
import glob;
import sys;
import re;
import smtplib;

from urllib.request import urlopen;
# 返回当前的工作目录
def getCwd():
    return os.getcwd();


# 获取当前工作目录所有以py结尾的文件
def fileList():
    return glob.glob("*.py");


def strRegx():
    list1 = re.findall(r'\bf[a-z]*', 'which foot or hand fell fastest')

    print(list1);

    list2 = re.sub(r'(\b[a-z]+) \1', r'\1', 'cat in the the hat');

    print(list2);

def urllibdemo():
    for line in urlopen("http://www.miaoe.com"):
        print(line.decode("UTF-8"));


# 发邮件
def emaildemo():
    server = smtplib.SMTP("localhost");
    server.sendmail("zsjdxc251@163.com","zsjdxc251@qq.com","python test send email");
    server.close();


from datetime import date;
from datetime import datetime;
#   日期时间
def datatimedemo():
    now = date.today();

    # 格式化日期
    formatime = now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.");
    print( formatime)
    # 指定时间
    birthday = date(1964, 7, 31);
    # 当前时间减去指定时间
    age = now - birthday;
    # 相差天数
    print( age.days);

    pass;


import zlib;
# 数据压缩
def datacompress():
    s = b'witch which has which witches wrist watch';
    print(len(s));
    # 压缩
    t = zlib.compress(s);
    print(len(t));
    # 解压
    s = zlib.decompress(t)
    print(s);
    print( zlib.crc32(s));
    pass;

from timeit import Timer
# 性能度量
def propertytest():
    print(Timer('t=a; a=b; b=t', 'a=1; b=2').timeit());
    pass;




#print(sys.argv)
#sys.stderr.write('Warning, log file not found starting a new one\n')

#print(fileList())
testmodel();